package com.googlecode.moneyManager.excelReader;

import com.googlecode.moneyManager.config.SpringApplicationContext;
import com.googlecode.moneyManager.model.Currency;
import com.googlecode.moneyManager.model.dto.InputSecurityDTO;
import com.googlecode.moneyManager.reader.DataValueProvider;
import com.googlecode.moneyManager.service.SecurityValueService;

/**
 * Author: Sergiy Doroshenko
 * Date: Apr 26, 2010
 * Time: 11:19:34 PM
 */

public class ReaderExe {
    public static void main(String[] args) {

        DataValueProvider provider = SpringApplicationContext.getBean(DataValueProvider.class);
        SecurityValueService service = SpringApplicationContext.getBean("securityValueService",SecurityValueService.class);
        try {
            String baksPart = provider.getPartAmount(Currency.USD);
            String evroPart = provider.getPartAmount(Currency.EUR);
            String grivnaPart = provider.getPartAmount(Currency.UAH);

            String baksRate = provider.getRate(Currency.USD);
            String evroRate = provider.getRate(Currency.EUR);


            String grivnaAll = provider.getSumAmount(Currency.UAH);
            String baksAll = provider.getSumAmount(Currency.USD);
            System.out.println(baksAll);
            System.out.println(grivnaAll);
            System.out.println(baksPart);
            System.out.println(grivnaPart);
            System.out.println("evroPart=" + evroPart);
            System.out.println("baksRate = " + baksRate);
            System.out.println(evroRate);
            InputSecurityDTO inputSecurityDTO = new InputSecurityDTO();
            inputSecurityDTO.baksAll = baksAll;
            inputSecurityDTO.grivnaAll = grivnaAll;
            inputSecurityDTO.baksPart = baksPart;
            inputSecurityDTO.evroPart = evroPart;
            inputSecurityDTO.grivnaPart = grivnaPart;
            inputSecurityDTO.baksRate = baksRate;
            inputSecurityDTO.evroRate = evroRate;
            service.addValues(inputSecurityDTO);
            
//            service.addValue(baksAll, TypeSecurityValue.ALL, Currency.USD);
//            service.addValue(grivnaAll, TypeSecurityValue.ALL,Currency.UAH);
//            service.addValue(baksPart, TypeSecurityValue.PART, Currency.USD);
//            service.addValue(evroPart, TypeSecurityValue.PART, Currency.EUR);
//            service.addValue(grivnaPart,TypeSecurityValue.PART,Currency.UAH);
//            service.addValue(baksRate,TypeSecurityValue.RATE,Currency.USD);
//            service.addValue(evroRate, TypeSecurityValue.RATE, Currency.EUR);
            
        } catch(Exception ioe) {
            ioe.printStackTrace();
        }
    }
}